<template>
  <div>
    <h2>正则练习</h2>
    <h3>全局替换 +、-、*、/，四则运算符号</h3>
    <input type="text" v-model="str" />
    <div>替换后：{{ result }}</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      str: "a+b*c/b-h+z",
      result: [],
    };
  },
  watch: {
    str: {
      immediate: true,
      handler(n) {
        let temp = n.replace(/\+|\-|\*|\//g, ",");
        this.result = temp.split(",");
      },
    },
  },
};
</script>

<style lang="less" scoped></style>
